package cn.edu.zut.internship.web.controller.sys;

import cn.edu.zut.internship.bean.sys.Result;
import cn.edu.zut.internship.bean.sys.SysUser;
import cn.edu.zut.internship.iservice.sys.SemesterSV;
import cn.edu.zut.internship.web.utils.UserInfoUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/semester")
public class SemesterController {
    @Reference
    private SemesterSV semesterSV;

    /**
     * 新建学期
     * @param params
     * @return
     */
    @RequestMapping("/newSemester")
    public Result newSemester(@RequestBody Map params){
        Result result = new Result();
        SysUser userInfo = UserInfoUtil.getUserInfo();
        String userAccount = userInfo.getUserAccount();
        params.put("creatAccount",userAccount);
        result = semesterSV.newSemester(params);
        return result;
    }

    /**
     * 获取学期列表
     * @return
     */
    @RequestMapping("/getSemesterList")
    public Result newSemester(){
        Result result = new Result();
        result = semesterSV.getSemesterList();
        return result;
    }
}
